#include "h_cc2640r2f_define.h"

#include <stdio.h>
#include <stdarg.h>

#include "h_cc2640r2f_uart.h"
#include "s_sc_uart.h"

#include <icall_ble_api.h>

unsigned char H_CC2640R2F_MAC_ADDR[6] = {0x99, 0x99, 0x66, 0x66, 0x99, 0x99};


#define H_CC2640R2F_printTxbuff                  S_SC_UART_WriteBuff//H_CC2640R2F_UART_TxBuff

static char buf[H_CC2640R2F_UART_RxLength];
void H_CC2640R2F_UART_Debug(const char* format, ...)
{
    va_list arg;
    va_start(arg, format);
//    char buf[H_CC2640R2F_UART_RxLength];
    unsigned short len;
    len = vsprintf((char*)buf, format, arg);
    H_CC2640R2F_printTxbuff(buf, len);
}


#define STR2HEX_LEN     128
static char str2hexdata[STR2HEX_LEN];
void str2hex(unsigned char *pAddr, unsigned short len)
{
  unsigned char     charCnt;
  char        hex[] = "0123456789ABCDEF";
//  static char str[(2*B_ADDR_LEN)+3];
//  char *str = (char*)str2hex_malloc(sizeof(char) * (len + 1));
//  if(NULL == str)
//  {
//    return NULL;
//  }

  char        *pStr = str2hexdata;


  for (charCnt = 0; charCnt < len; charCnt++)
  {
    *pStr++ = hex[*pAddr >> 4];
    *pStr++ = hex[*pAddr++ & 0x0F];
  }

  *pStr = '\0';

  pStr = NULL;

//  return str;
}

void H_CC2640R2F_UART_Debugprinthex(unsigned char *data, unsigned short len)
{
    str2hex(data, len);
    H_CC2640R2F_UART_Debug("%s\r\n", str2hexdata);

//    while(len--)
//    {
//
//        H_CC2640R2F_UART_Debug("%02x", *data++);
//    }
//    H_CC2640R2F_UART_Debug("\r\n");

}

